/**
 * Created by jihb on 4/13/16.
 */
Ext.define('JYnovel.controller.system.LoginController',{
    extend:'Ext.app.Controller',
    views:[
        'system.LoginView'
    ],
    models:[

    ],
    stores:[

    ],
    refs:[{
        ref:'LoginFormView',
        selector:'LoginFormView'
    }],
    init:function () {
        this.control({
            'LoginFormView button[name=loginOkBtn]':{
                click:this.loginOkBtnClick
            },
            'LoginFormView textfield':{
                keyup:this.enterKeyDoLogin
            }
        });
    },
    /**
     * 登录
     */
    loginOkBtnClick:function (btn,eOpts) {
        ExtSubmitForm(btn.up("form"),getUrl("/dologin"),function () {
            window.location.href = getUrl("/index");
        });
    },
    enterKeyDoLogin:function ( textfield, e, eOpts) {
        if(e.keyCode == Ext.EventObject.ENTER){
            var btn = this.getLoginFormView().down('button[name=loginOkBtn]');
            btn.fireEvent('click',btn);
        }
    }
});